import { AES, enc } from 'crypto-ts'
const SECRET_KEY = 'kbhb'
// 11自定义序列化器
const encryptedSerializer = {
    serialize: (value: any) => {
        const jsonString = JSON.stringify(value)
        const encrypted = AES.encrypt(jsonString, SECRET_KEY).toString()
        return encrypted
    },
    deserialize: (value: string) => {
        const bytes = AES.decrypt(value, SECRET_KEY)
        const decrypted = bytes.toString(enc.Utf8)
        return JSON.parse(decrypted)
    }
}

export { encryptedSerializer }